$().ready(
               function () {

                   $('#tabs li a').featureList({
                        output			:	'#output li',
                        start_item		:	1
                    });


                   $('ul.top-menu li').jrumble({
                                               x: 2,
                                               y: 2,
                                               rotation: 1
                                              });
                   $('ul.top-menu li').mousedown(function(){
                       $(this).trigger('startRumble');
                   });

                   $('ul.top-menu li').mouseup(function(){
                       $(this).trigger('stopRumble');
                   });

                   $('ul.top-menu li').mouseout(function(){
                      $(this).trigger('stopRumble');
                  });


//                 ###############  PLACEHOLDER FIX################

                   $('[placeholder]').focus(function() {
                     var input = $(this);
                     if (input.val() == input.attr('placeholder')) {
                       input.val('');
                       input.removeClass('placeholder');
                     }
                   }).blur(function() {
                     var input = $(this);
                     if (input.val() == '' || input.val() == input.attr('placeholder')) {
                       input.addClass('placeholder');
                       input.val(input.attr('placeholder'));
                     }
                   }).blur();

//                 ###############  PLACEHOLDER FIX################








                   $.isFunction($.fn.zoomy) && $(".zoom").zoomy("mouseover", {zoomSize:200, round:true, glare:false, clickable:true, attr:"data-zoom"});
              // ZABOR







                       $('.title').click(function() {

                           if($(this).parent().find('.inner_text').first().css('display')=='block'){
                                return false;
                           }

                           var target = $(this);
                           $('.item .title').each(function(){
                              var el = $(this).parent().find('.inner_text');

                              if(el.css('display')=='block'){
                                  el.slideDown('slow');
                              }
                          });

                          $(this).parent().find('.inner_text').slideUp('slow', function(){
                              $(this).css('display', 'block')});
                      });

                      $('#accordion').accordion();



                    $('.top-menu li').not('#work-menu').click(function (event) {
                        var myurl=$(this).attr('data-url');
                        $('.content').addClass('otstup').removeClass('zabratu');
                        $('.submenu').css('display','none');
                       $('.backsubmenu').slideUp('slow', function () {
                         showPage(myurl);
			              });
                       $('.top-menu li').removeClass('selected');
                       $(this).addClass('selected');
                       
                       
                       
                      


                   });

                   $('#work-menu') .click(function(){
                       stopRotation();
                       startRotation();
                       $('.content').addClass('zabratu').removeClass('otstup');
                       $('.top-menu li').removeClass('selected');
                                            $(this).addClass('selected');
                       $('.current').css('display','none');
                       $('.backsubmenu').css('display','block');
                       $('.submenu').slideDown('slow', function () {showcontentblock();               stopRotation(); });
                   });

                   function showcontentblock(){
                       $('.current').slideDown('slow');
                   }
                   $('.sub-menu li').click(function () {
                       $('.sub-menu li').removeClass('selected');
                       $(this).addClass('selected');
                       showPage($(this).attr('data-url'));
                   });


                 

                   /**
                    * Main function
                    * @param id
                    */
                   var showPage = function (id) {
//                     if (curPosition == position)return false;

                       var el = $('div.current')[0];
                       el = $(el);
                       if(el.attr('id')==id)return false;

                       var nextElement = $('#'+id);
                       if(nextElement.length==0){
//                           console.log('page not found');
                           return false;
                       }
                       stopRotation();
                       startRotation();
                       el.stop();
                       el.animate({
                           marginLeft:'-100px',
                           opacity:0
                       }, 400, function(){
                           $(this).css('display', 'none').removeClass('current');
                       });

                       nextElement.css('margin-left', '100px').css('display', 'block').animate({
                                   marginLeft:'0',
                                   opacity:1
                               }, 1000,
                               function () {
                                   stopRotation();
                               }).addClass('current');
                   };

                   var angle=10;
                   var mytimer;

                   var startRotation = function(){
                     mytimer = setInterval(
                       function () {
                           $('#g2').rotate(angle);
                           var min = angle*-1;
                           $('#g1').rotate(min);
                           angle+=10;
                       },
                       100
                   );
                   };

                   var stopRotation = function(){
                     clearInterval(mytimer);
                   };


                  $('div.gears').mouseover(function(){
                      stopRotation();
                      startRotation();
                  })
                   $('div.gears').mouseout(function(){
                                         stopRotation();

                                     })


               });
